import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'

//添加全局样式
import './assets/css/global.css'
//引入iconfont
import './assets/font/iconfont.css'
//引入QRCode
import QRCode from 'qrcodejs2'
import qs from "qs";
// 导入axios
import axios from 'axios'
// 挂载axios 到Vue的原型prototype的$http
Vue.prototype.$http = axios

Vue.prototype.$qs = qs
// 设置请求的根路径
axios.defaults.baseURL = "http://127.0.0.1:9000/"
//axios.defaults.headers['Content-Type'] = "application/x-www-form-urlencoded";
axios.interceptors.request.use(
  config => {
    console.log(config);
    // 获取token
    const tokenStr = window.sessionStorage.getItem("Token");// session取值
    if (tokenStr) {
      // 请求头挂载信息
      config.headers['Token'] = "Bearer " + window.sessionStorage.getItem("Token");
    }
    // 在最后必须return config
    return config;
  },
  error => {  // 当发生错误时，执行该部分代码
    console.log(error); //调试用
    return this.$message.error("Cloud无法提供服务!");
    return Promise.reject(error)
  })

Vue.config.productionTip = false

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
